//
//  ViewController2.m
//  QQLoginDemo
//
//  Created by 郑东喜 on 2016/11/4.
//  Copyright © 2016年 BateOrganization. All rights reserved.
//

#import "ViewController2.h"

#import "TencentTool.h"

#import "AppDelegate.h"

@interface ViewController2 ()<QQShareDelegate> {
    AppDelegate *appdelegate;
}

/**
 tencentTool
 */
@property (nonatomic,strong) TencentTool *tool;
- (IBAction)qqLogin:(id)sender;
- (IBAction)qqShare:(id)sender;

@end

@implementation ViewController2

- (TencentTool *)tool {
    if (!_tool) {
        _tool = [[TencentTool alloc] init];
    }
    return _tool;
}

- (IBAction)qqLogin:(id)sender {
    [self.tool qqLogin];
}

- (IBAction)qqShare:(id)sender {
    [self.tool qqShare];
    appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    appdelegate.qqDelegate = self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)shareSuccssWithQQCode:(NSInteger)code{
//    NSLog(@"code %ld",(long)code);
    
    NSLog(@"%s  %d  code%ld",__func__,__LINE__,(long)code);
    if (code == 0) {
        UIAlertView *aler = [[UIAlertView alloc]initWithTitle:@"警告" message:@"分享成功" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [aler show];
    }else{
        UIAlertView *aler = [[UIAlertView alloc]initWithTitle:@"警告" message:@"分享失败" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [aler show];
    }
}


@end
